package jiubeirobot.com.robotshop.ui.activity.manange;

import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.OnClick;
import jiubeirobot.com.robotshop.BuildConfig;
import jiubeirobot.com.robotshop.R;
import jiubeirobot.com.robotshop.base.BaseActivity;
import jiubeirobot.com.robotshop.base.BaseBean;
import jiubeirobot.com.robotshop.bean.AccountInfoBean;
import jiubeirobot.com.robotshop.bean.LoginManageBean;
import jiubeirobot.com.robotshop.bean.ObjBean;
import jiubeirobot.com.robotshop.common.view.CircularImageView;
import jiubeirobot.com.robotshop.data.net.APIManager;
import jiubeirobot.com.robotshop.data.net.Flags;
import jiubeirobot.com.robotshop.data.net.URLS;
import jiubeirobot.com.robotshop.ui.activity.SetRobotActivity;
import jiubeirobot.com.robotshop.utils.L;
import jiubeirobot.com.robotshop.utils.QRCodeUtil;
import jiubeirobot.com.robotshop.utils.SharedPreferencesUtils;
import jiubeirobot.com.robotshop.utils.glide.GlideImageLoadImpl;

/**
 * @author TheJoker丶豪
 *         显示初始设置的页面
 * @date 创建时间:2017/8/22
 */
public class ShowSetActivity extends BaseActivity {
    @BindView(R.id.iv_search_icon)
    ImageView ivsearch;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.llyt_back)
    LinearLayout llback;

    @BindView(R.id.civ_head_photo)
    CircularImageView headphoto;
    @BindView(R.id.tv_user_name)
    TextView username;
    @BindView(R.id.tv_account_name)
    TextView accountname;
    @BindView(R.id.tv_user_account)
    TextView useraccount;
    @BindView(R.id.iv_Members_invited)
    ImageView ivmembersinvited;
    @BindView(R.id.iv_open_shop)
    ImageView ivopenshop;
    @BindView(R.id.tv_account_number)
    TextView tv_account_number;
    @BindView(R.id.tv_address_info)
    TextView tv_address_info;


    String delivery_id;

    @Override
    public int pageLayout() {
        return R.layout.activity_show_set;
    }

    @Override
    public void initTitle() {
        ivsearch.setVisibility(View.GONE);
        tvTitle.setText(getString(R.string.inilite_set));
    }

    @Override
    protected boolean isOpenStatus() {
        return super.isOpenStatus();
    }

    @Override
    public void initView() {
        headphoto.setBorderWidth(0);
        delivery_id = SharedPreferencesUtils.getString(this, "delivery_id");
        APIManager.getInstance().getAccountInfo(this, delivery_id);
    }

    @Override
    public void onSuccess(BaseBean bean, int flag) {
        switch (flag) {
            case Flags.FLAG_GET_ACCOUNT_INFO:
                BaseBean<ObjBean<AccountInfoBean>> infobean = bean;
                AccountInfoBean accountInfoBean = infobean.getData().getObj();
                username.setText(accountInfoBean.getShop_name());
                accountname.setText(accountInfoBean.getAccount());
                GlideImageLoadImpl.getInstance().load(ShowSetActivity.this, accountInfoBean.getShop_photo(), headphoto);
                tv_account_number.setText(SharedPreferencesUtils.getString(this,"delivery_id"));
                QRCodeUtil.createQRImage(BuildConfig.SERVER_IP + URLS.URL_SHARE_CODE, ivmembersinvited);
                QRCodeUtil.createQRImage(BuildConfig.SERVER_IP + URLS.URL_SHARE_CODE, ivopenshop);
                break;
            default:
                break;
        }
        dismissHUD();

    }

    @OnClick({R.id.llyt_back})
    public void onclick(View view) {
        switch (view.getId()) {
            case R.id.llyt_back:
                finish();
                break;
            default:
                break;
        }
    }
}
